package com.mtnz.njk.Controller;

import com.mtnz.njk.Service.AskManageService;
import com.mtnz.njk.result.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/ask")
public class AskManangeController {
    @Autowired
    AskManageService askManageService;

    /**
     * 提问列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @PostMapping("/askList")
    public ResponseResult askList(@RequestParam(defaultValue = "1")Integer pageNum, @RequestParam(defaultValue = "10")Integer pageSize) throws Exception {
        return askManageService.askList(pageNum, pageSize);
    }

    /**
     * 查询提问列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @PostMapping("/checkAskList")
    public ResponseResult checkAskList( String key,@RequestParam(defaultValue = "1")Integer pageNum, @RequestParam(defaultValue = "10")Integer pageSize) throws Exception {
        return askManageService.checkAskList(key, pageNum, pageSize);
    }

    /**
     * 删除提问
     * @return
     * @throws Exception
     */
    @PostMapping("/delAsk")
    public ResponseResult delAsk(String askId)throws Exception{
        return askManageService.delAsk(askId);
    }

    /**
     * 评论列表
     * @param askId
     * @param pageNum
     * @param pageSize
     * @return
     * @throws Exception
     */
    @PostMapping("/AskCommentList")
    public ResponseResult AskCommentList(String askId, @RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize)throws Exception{

        return askManageService.AskCommentList(askId,  pageNum, pageSize);
    }

    /**
     * 删除评论
     * @param commentAskId
     * @return
     * @throws Exception
     */
    @PostMapping("/delAskComment")
    public ResponseResult delAskComment(String commentAskId)throws Exception{
        return askManageService.delAskComment(commentAskId);
    }

    /**
     * 添加提问评论
     *
     * @return
     */
    @PostMapping("/addCommentAsk")
    public ResponseResult addCommentAsk(String askId, String userId, String message, String img) {
        return askManageService.addCommentAsk(askId, userId, message, img);
    }

    /**
     * 回复评论
     *
     * @param userId
     * @param askId
     * @param message
     * @param commentAskId
     * @return
     */
    @PostMapping("/commentAskReply")
    public ResponseResult commentAskReply(String userId, String askId, String message, String commentAskId) {
      return askManageService.commentAskReply(userId, askId, message, commentAskId);
    }

    /**
     * 回复评论回复
     *
     * @param askId 提问
     * @param userId     用户
     * @param message    内容
     * @param pid        上一条回复的ID
     * @return
     */
    @PostMapping("/commentAskReplys")
    public ResponseResult commentAskReplys(String userId, String askId, String message, String replyId, String pid) {
      return askManageService.commentAskReplys(userId, askId, message, replyId, pid);
    }

    /**
     * 研究院统计
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param status  0月1年
     * @return
     */
    @PostMapping("/askStatistics")
    public ResponseResult askStatistics(String startTime, String endTime, String status)throws Exception{
        return askManageService.askStatistics(startTime, endTime, status);
    }
}
